package hijava;

import java.util.Objects;

/**
 * 演示Object 类的一些方法
 */
public class Cat{
    private int number;
    private String color;
    private int age;
    private Cat mother;



    public static  void showCat(Cat cat){
        System.out.println(cat);
        cat.setAge(88);
    }

    @Override
    public String toString() {
        return "Cat{color='" + color + '\'' + ", age=" + age + '}';
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cat cat = (Cat) o;
        return number == cat.number;
    }

    @Override
    public int hashCode() {
        return Objects.hash(number);
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("死之前有什么遗言就在这里交代！");
    }

    public String getColor() {
        return color;
    }

    public Cat setColor(String color) {
        this.color = color;
        return this;
    }

    public int getAge() {
        return age;
    }

    public Cat setAge(int age) {
        this.age = age;
        return this;
    }


    public int getNumber() {
        return number;
    }

    public Cat setNumber(int number) {
        this.number = number;
        return this;
    }

    public Cat getMother() {
        return mother;
    }

    public Cat setMother(Cat mother) {
        this.mother = mother;
        return this;
    }
}
